//
//  UIImage+ImageDowloader.m
//  UI_08_03_图片下载
//
//  Created by lanou3g on 15/8/3.
//  Copyright (c) 2015年 王钧. All rights reserved.
//

#import "UIImage+ImageDowloader.h"

@implementation UIImage (ImageDowloader)

+(void)dowLoadImageWithURL:(NSString *)SURL andBlock:(ImageBlock)block
{
    //1.生成URL
    NSURL *url = [[NSURL alloc]initWithString:SURL];
    //2.生成请求对象
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL:url];
    //3.发送数据请求
    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
        UIImage *image = [UIImage imageWithData:data];
        block(image);
    }];
}

@end
